package com.ff.xyh.consumer.messagedeliver.listener;

import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.time.LocalTime;

/**
 * @Auther FF
 * @Date 2022年 11月 30日
 * @Time 00:38
 */
//@Component
public class UserListener {

        // 直接监听队列
        @RabbitListener(queues = "checkBanned")
        public void listenBannedQueue(Object object) {
            System.out.println("listenFanoutQ1 received the message: {" + object + "}, when " + LocalTime.now());
        }

        // 绑定队列并监听
        @RabbitListener(bindings = @QueueBinding(
                value = @Queue( name = "directQ1"),
                exchange = @Exchange(name = "directEx1", type = ExchangeTypes.DIRECT),
                key = {"abc","cde"}
        ))
        public void listenDirectQ1(Object object) {
            System.out.println("listenDirectQ1 received the message: {" + object + "}, when " + LocalTime.now());
        }

}
